import { createApp } from 'vue';
import { setupStore } from '@/store';
import router from '@/router';
import App from './App.vue';
// import 'virtual:svg-icons-register';
import '@/styles/app.scss';
import 'vant/lib/index.css';
// import directive from "./directive";
import { i18n, setLocale } from './locales';
import { setToastDefaultOptions } from 'vant';

setToastDefaultOptions({ forbidClick: true });

async function setupApp() {
  const app = createApp(App);

  setupStore(app);

  app.use(router);

  app.use(i18n);

  app.mount('#app');

  setLocale();

  // directive(app)
	app.config.globalProperties.$serverImg = import.meta.env.VITE_serverImg;

  if (import.meta.env.VITE_PROD_CONSOLE == 'Y') {
    import('vconsole').then(res => {
      new res.default();
    });
  }
}

setupApp();

window.onerror = function(message, source, lineno, colno, error) {
  console.error('发现错误:', message, source, lineno, colno, error);
}
